package cn.zyy.hotel.service.impl;

import cn.zyy.hotel.dao.NoticeMapper;
import cn.zyy.hotel.entity.Notice;
import cn.zyy.hotel.service.NoticeService;
import cn.zyy.hotel.vo.NoticeVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class NoticeServiceImpl implements NoticeService {

    @Resource
    private NoticeMapper noticeMapper;

    //查询所有公告
    @Override
    public List<NoticeVO> selectNoticeList(NoticeVO noticeVO) {
        return noticeMapper.selectNoticeList(noticeVO);
    }

    //添加公告
    @Override
    public int addNotice(Notice notice) {
        notice.setCreateDate(new Date());
        return noticeMapper.addNotice(notice);
    }

    //修改公告
    @Override
    public int updateNotice(Notice notice) {
        notice.setModifyDate(new Date());
        return noticeMapper.updateNotice(notice);
    }

    //删除公告
    @Override
    public int deleteById(Integer id) {
        return noticeMapper.deleteById(id);
    }
}
